<table width="100%">
<?php
$i=0;
$sum = 0.00;
$ilosc_typow = 0;
foreach ($items as $item){
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
	$ilosc_typow = 0;
	foreach ($item['StoreType'] as $type) {
		$ilosc_typow += $type['amount'];
	}	
?>
	<tr<?php echo $class;?>>
		<td width="10%">
			<?php echo $this->Html->link($fileUpload->image($item['StoreUpload']['name'],array('autoResize'=>true,'width'=>40,'imagePathOnly'=>false))
				, array('plugin'=>'store','controller'=>'products','action' => 'view', $item['StoreProduct']['id']),array('escape'=>false,'title'=>$item['StoreProduct']['name'])); ?>&nbsp;
		</td>
		<td  width="90%" class="actions">
			<?php if($item['StoreProduct']['price_przecena'] > 0 && $item['StoreProduct']['price_promocja'] == 0){?>
					<?php
						$price = str_replace(',', '.', $item['StoreProduct']['price_przecena']) * $ilosc_typow;	
						$price_detal = str_replace(',', '.', $item['StoreProduct']['price_detaliczna'])*$ilosc_typow;								
						$sum += $price;
					?>
					<span class="product-view-price-discount"><?php echo $this->Store->price($price_detal,2,'','',$item['StoreProduct']['currency_id'],$item['StoreCurrency']['exchange']);?></span> 
					<span class="product-view-price"><?php echo $this->Store->price($price,2,null,null,$item['StoreProduct']['currency_id'],$item['StoreCurrency']['exchange'])?></span>
					 
			<?php }else if( $item['StoreProduct']['price_promocja'] > 0){?>
					<?php
						$price = str_replace(',', '.', $item['StoreProduct']['price_promocja']) * $ilosc_typow;	
						$price_detal = str_replace(',', '.', $item['StoreProduct']['price_detaliczna'])*$ilosc_typow;								
						$sum += $price;
					?>
					<span class="product-view-price-discount"><?php echo $this->Store->price($price_detal,2,'','',$item['StoreProduct']['currency_id'],$item['StoreCurrency']['exchange']);?></span> 
					<span class="product-view-price"><?php echo $this->Store->price($price,2,null,null,$item['StoreProduct']['currency_id'],$item['StoreCurrency']['exchange'])?></span>

			<?php }else{?>
					<?php
						$price = str_replace(',', '.', $item['StoreProduct']['price_detaliczna']) * $ilosc_typow;									
						$sum += $price;
					?>
					<span class="product-view-price"><?php echo $this->Store->price($price,2,null,null,$item['StoreProduct']['currency_id'],$item['StoreCurrency']['exchange'])?></span>

			<?php }?>
		</td>
	</tr>
<?php } ?>

	
	<?php if(isset($delivery) && is_array($delivery) && !empty($delivery)){?>
	<tr<?php echo $class;?>>
		<td colspan="2" align="right" width="100%" class="actions total-cart">		
			<?php 
				echo __d("store","Delivery costs: ")?><span class="product-view-price"><?php echo $this->Store->price($delivery['price'],2,null,null,$delivery['currency_id'],$delivery['exchange'])?></span>
				<?php $sum += $delivery['price']; ?>
		</td>
	</tr>
	<?php }?>
	<tr<?php echo $class;?>>
		<td colspan="2" align="right" width="100%" class="actions total-cart">
		
			<?php echo __d("store","Razem: ")?><span class="product-view-price"><?php echo $this->Store->price($sum,2,null,null,$this->Session->read('Store.selected_currency'),$this->Session->read('Store.selected_exchange'))?></span>
		</td>
	</tr>
</table>
<?php echo $html->link(__d("store","Schow Cart",true),array('plugin'=>'store','controller'=>'carts','action'=>'cart_view'),array('class'=>'button float-right'))?>
